<?

session_start();
if($_SESSION["memberId"] == null || $_SESSION["memberId"] == "")
{
	header("Location:../login.php");
}else{
	$memberId = $_SESSION["memberId"];
}



//$memberId = 1;


include_once("../Dao/db.php");





$max_length = 200;
$err_message = "";

if(isset($_POST['TagRegist']) && $_POST['TagRegist']!='' ){
	$cv_point_name = $_POST['cv_point_name'];
	$url = $_POST['url'];
	$salesValue = $_POST['salesValue'];
	
	if(mb_strlen($cv_point_name)>255 || $cv_point_name==''){
		$err_message .= "・成果地点名は1文字以上50文字以内で入力してください。<br/>";	
	}

	if(mb_strlen($url)>255 || $url == ''){
		$err_message .= "・URLが未記入もしくは、URLの文字数が255文字以上です。<br/>";	
	}
	
	if(!preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/i',$url,$matche)){
		$err_message .= "・URLは255文字以内で入力してください。<br/>";	
	}
	
	if(!is_numeric($salesValue) || $salesValue<0){
		$err_message .= "・売上単価の入力データフォーマットは、0以上の整数となります。<br/>";			
	}
	
	if($err_message==""){
		$sql = "insert into cvpoint(memberId,name,url,registDate,salesValue) values($memberId,'$cv_point_name','$url',now(),$salesValue);";
		$result = mysql_query($sql);
		if(mysql_insert_id()==0){
			$complete_messege = "同一URL:$url"."で既に登録されています。";
		}else{
			$complete_messege = "登録が完了しました。";		
		}
	}	
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>タグ発行 ＞ コンバージョンタグ
＞新規登録</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../css/common.css" type="text/css" />
<script language="JavaScript" src="../js/common.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#F4FFE4">
<?php include("../head.php") ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">

 <tr>
    <td width="151" valign="top" bgcolor="#5C743D"><?php include("../menu.php");?></td>
    <td width="813" colspan="2" align="center" valign="top">

<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tbody><tr>
		<td class="menu_path_left"></td>
		<td class="menu_path">タグ発行 ＞ <a href="TagList.php">コンバージョンタグ</a>＞<a href="TagRegist.php">新規登録</a></td>
		<td class="menu_path_right"></td>
	</tr>
</tbody></table>
<? echo $err_message."<br/>"; ?>
<? echo $complete_messege;?>
<form action="TagRegist.php" method="post" name="TagRegist">
  <div class="input_area">
	<table border="0" cellpadding="2" cellspacing="0" width="100%">
		<tbody><tr>
			<td align="right">
				<input class="btn save" value="" onclick="document.TagRegist.submit();" type="submit">
			</td>
		</tr>
	</tbody></table>
	<table class="tbl" border="0" cellpadding="4" cellspacing="0" width="100%">
		<tbody><tr>
			<td class="td9" align="left"><span class="required">成果地点名</span></td>
			<td class="td4 left">
				<input name="cv_point_name" size="60" maxlength="40" value="" class="txBox" type="text">
			</td>
		</tr>
		<tr>
			<td class="td9 top" align="left"><span class="required">URL</span></td>
			<td class="td4 border">
				<input name="url" size="60" maxlength="1000" value="" class="txBox" type="text">
				<input name="TagRegist" type="hidden" id="TagRegist" value="1" />
			</td>
		</tr>
		<tr>
		  <td class="td9 top" align="left">売上単価</td>
		  <td class="td4 border"><p>
		          <input name="salesValue" type="text" id="salesValue" />
		      円　(売り上げ単価の概念がない場合、0を入力してください。)</p>		    </td>
		  </tr>
	</tbody></table>

</div>
</form>

<div id="input_area">
  <div class="input_area"><br />
    <br />
    <br>
	
</div>
</div>			<!-- end of main area -->   </td>

</table>
<?php include("../foot.php");?>  
</body>
</html>
